#include <bits/stdc++.h>
using namespace std;
int num[100000];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> num[i];
  }
  int leizhu = 0;
  int sum = 0;
  for (int i = 1; i <= n; ++i) {
    sum += num[i];
    if (sum < leizhu) {
      leizhu = sum;
    }
  }
  if (leizhu < 0) {
    cout << -leizhu << endl;
  }
  return 0;
}